package cn.otrue.patienthealthmanager.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.otrue.patienthealthmanager.R;
import cn.otrue.patienthealthmanager.bean.ThreadModel;

public class CommunityFragmentAdpater extends BaseAdapter {

	private List<ThreadModel> goods;
	private LayoutInflater inflater;
	private Context context;

	public CommunityFragmentAdpater(Context context,
			List<ThreadModel> goods) {
		super();
		this.goods = goods;
		this.context = context;
		inflater= LayoutInflater.from(this.context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return goods.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		arg1 = inflater.inflate(R.layout.community_partition_item, null);
		
		TextView tv_community_title = (TextView) arg1
				.findViewById(R.id.tv_community_title);
		TextView tv_community_name = (TextView) arg1
				.findViewById(R.id.tv_community_name);
		TextView tv_community_time = (TextView) arg1
				.findViewById(R.id.tv_community_time);
		TextView tv_community_num = (TextView) arg1
				.findViewById(R.id.tv_community_num);
		ThreadModel eachMap = goods.get(arg0);
		tv_community_title.setText(eachMap.getThreadTitle() + "");
		tv_community_name.setText(eachMap.getUseraccount() + "");
		tv_community_time.setText(eachMap.getCreatetime() + "");
		tv_community_num.setText(eachMap.getPraiseCount() + "");
		return arg1;
	}

}
